<template name="berths">
    {{#if isAdmin}}
    <p class="text-right">
    <button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button></p>
    {{/if}}
    <div class="row show-grid">
        <div class="col-xs-4 col-sm-4 theader">车位({{occupation}}/{{totalCount}})</div>
        <div class="col-xs-4 col-sm-4 theader">用户</div>
        <div class="col-xs-4 col-sm-4 theader">操作</div>
    </div>
    {{#each berths}} 
    <div class="row show-grid berth-list">
        <div class="col-xs-4 col-sm-4">{{berthNumber}}</div>
        {{#if userId}} 
                    {{#if isBelongtoCurrUser userId}}
                        <div class="col-xs-4 col-sm-4">
                            <a role="button" class="btn" aria-label="Left Align" data-toggle="modal" data-target=".{{user.profile.username}}">
                                <span class="glyphicon glyphicon-info-sign"></span>{{user.profile.username}}
                            </a>
                            <div class="modal fade {{user.profile.username}}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title" id="myModalLabel">{{user.profile.username}}</h4>
                                        </div>
                                        <div class="modal-body">
                                            <ul class="list-group">
                                                <li class="list-group-item">{{user.profile.plateNO}}</li>
                                                <li class="list-group-item">
                                                    <a href="tel:{{user.profile.cellphone}}" title="{{user.profile.cellphone}}">
                                                        <span class="glyphicon glyphicon-earphone">{{user.profile.cellphone}}</span>
                                                    </a>
                                                </li>
                                                <li class="list-group-item">
                                                    <a href="mailto:{{user.profile.cellphone}}" title="{{user.profile.cellphone}}">
                                                        <span class="glyphicon glyphicon-send">{{user.profile.email}}</span>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4 col-sm-4">
                            <a href="#" class="btn btn-primary btn-sm option" role="button" data-status="1">取消</a>
                        </div>
                    {{else}}
                        <div class="col-xs-4 col-sm-4">
                            <a role="button" class="btn" aria-label="Left Align" data-toggle="modal" data-target=".{{user.profile.username}}">
                                <span class="glyphicon glyphicon-info-sign"></span>{{user.profile.username}}
                            </a>
                            <div class="modal fade {{user.profile.username}}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title" id="myModalLabel">{{user.profile.username}}</h4>
                                        </div>
                                        <div class="modal-body">
                                            <ul class="list-group">
                                                <li class="list-group-item">{{user.profile.plateNO}}</li>
                                                <li class="list-group-item">
                                                    <a href="tel:{{user.profile.cellphone}}" title="{{user.profile.cellphone}}">
                                                        <span class="glyphicon glyphicon-earphone">{{user.profile.cellphone}}</span>
                                                    </a>
                                                </li>
                                                <li class="list-group-item">
                                                    <a href="mailto:{{user.profile.cellphone}}" title="{{user.profile.cellphone}}">
                                                        <span class="glyphicon glyphicon-send">{{user.profile.email}}</span>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4 col-sm-4">
                            <a href="#" class="btn btn-sm disabled" role="button" data-status="0">预定</a>
                        </div>
                    {{/if}}
        {{else}}
            
            <div class="col-xs-4 col-sm-4">未预定</div>
            <div class="col-xs-4 col-sm-4">
            {{#if currentUser}}
                <a href="#" class="btn btn-primary btn-sm option" role="button" data-status="0">预定</a>
            {{else}}
                <a href="#" class="btn btn-sm option disabled" role="button" data-status="0">预定</a>
            {{/if}}
            </div>
        {{/if}}
    </div>
    {{#if currentUser}}
        {{hideButton}}
    {{/if}}
    {{/each}}

</template>

<template name="updateBerthForm">
  {{> quickForm collection="Berth" doc=this id="updateBerthForm" type="update"}}
</template>
